package com.sxkj.gis.datastorage.shapefiles.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sxkj.gis.datastorage.shapefile.bean.ShapeFileInfo;
import com.sxkj.gis.datastorage.shapefiles.service.DataStorageService;

@Controller
public class DataStorageController {
	private static String basePath = DataStorageController.class.getClassLoader().getResource("data/").getPath();
	@Resource
	private DataStorageService dataStorageService;
	
	/**
	 * 跳转至Demonstration.jsp  演示页面
	 * @return
	 */
	@RequestMapping(value="/Demonstration.do")
	public String goDemonstration(){
		return "demonStration/Demonstration";
	}

	/**
	 * 跳转至dataStorage.jsp
	 * @return
	 */
	@RequestMapping(value="/dataStorage.do")
	public String goDataStroage(){
		return "data/datastorage/dataStorage";
	}
	
	/**
	 * dataStorage.jsp 中引入dataStoragelist.jsp
	 * @return
	 */
	@RequestMapping(value="/dataStoragelist.do")
	public String dataStoragelist(){
		return "data/datastorage/dataStoragelist";
	}
	
	/**
	 * 跳转至chooseDataStorage.jsp
	 * @return
	 */
	@RequestMapping(value="/chooseDataStorage.do")
	public String chooseDataStorage(){
		return "data/datastorage/chooseDataStorage";
	}
	/**
	 * 跳转至createDataStroage.jsp
	 * @return
	 */
	@RequestMapping(value="/createDataStorage.do")
	public String goCreateDataStorage(){
		return "data/datastorage/createDataStorage";
	}
	
	/**
	 * 跳转至dirbrowse.jsp
	 * @return
	 */
	@RequestMapping(value="godirbrowse.do")
	public String godirborowse(){
		return "data/datastorage/dirbrowse";
	}
	
	/**
	 * 根据传入的参数，获取文件夹下的文件
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value="getDir.do")
	public List<ShapeFileInfo> getDir(String target){
		System.out.println(basePath);
		List<ShapeFileInfo> filesList = dataStorageService.getFilesDir(target,basePath);
		System.out.println("size:"+filesList.size());
		
		return filesList;
	}
	
}
